func maxProfit(prices []int) int {
    var sum int
    for i:=0; i<len(prices)-1; i++{
        earnings := prices[i+1]- prices[i] 
        if earnings > 0 {
            sum += earnings
        }
    }
    return sum
}